package login

import (
	"context"

	v1 "web-ppt/api/login/v1"

	"web-ppt/internal/consts"

	"github.com/gogf/gf/v2/frame/g"
)

func (c *ControllerV1) Index(ctx context.Context, req *v1.IndexReq) (res *v1.IndexRes, err error) {
	r := g.RequestFromCtx(ctx)
	if c.session.Get(ctx, consts.User).IsNil() {
		c.view.RenderTpl(ctx, "login/index.html", nil)
	} else {
		r.Response.RedirectTo("/")
	}
	return
}
